﻿using System;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace LdtJudge.DataEngine.Model.XMLConfigModel.DataStores
{
    /// <summary>
    /// 优选配置
    /// </summary>
    [Serializable]
    [XmlRootAttribute("root", IsNullable = false)]
    public class OptimizeConfig
    {
        /// <summary>
        /// 数据源
        /// </summary>
        [XmlElementAttribute("sourcedatadefine", IsNullable = false)]
        public List<Sourcedatadefine> Sourcedatadefine { get; set; }

        /// <summary>
        /// 数据节点配置集合
        /// </summary>
        [XmlElementAttribute("xmllable", IsNullable = false)]
        public List<Xmllable> XmllableList { get; set; }
    }
    /// <summary>
    /// 数据源
    /// </summary>
    public class Sourcedatadefine
    {
        /// <summary>
        /// 数据项集合
        /// </summary>
        [XmlElementAttribute("sourcedata", IsNullable = false)]
        public List<Sourcedata> SourcedataList { get; set; }
    }
    /// <summary>
    /// 数据项
    /// </summary>
    public class Sourcedata
    {
        /// <summary>
        /// 数据标识
        /// </summary>
        [XmlAttribute("id")]
        public int id { get; set; }

        /// <summary>
        /// 数据唯一编码
        /// </summary>
        [XmlAttribute("code")]
        public string Code { get; set; }

        /// <summary>
        /// 数据源中文名称
        /// </summary>
        [XmlAttribute("name")]
        public string Name { get; set; }
        /// <summary>
        /// 阶段对应路径
        /// </summary>
        [XmlAttribute("path")]
        public string path { get; set; }

    }
    /// <summary>
    /// 数据节点
    /// </summary>
    public class Xmllable
    {
        /// <summary>
        /// 唯一标识
        /// </summary>
        [XmlAttribute("code")]
        public string Code { get; set; }

        /// <summary>
        /// 节点路径
        /// </summary>
        [XmlAttribute("xmlpath")]
        public string Xmlpath { get; set; }

        /// <summary>
        /// 优选类型
        /// </summary>
        [XmlAttribute("优选类型")]
        public string Type { get; set; }

        /// <summary>
        /// 优先级
        /// </XmlAttribute>
        [XmlAttribute("优先级")]
        public string Priority { get; set; }

        [XmlAttribute("优选条件")]
        public string Condition { get; set; }

        /// <summary>
        /// 属性配置集合
        /// </summary>
        [XmlElementAttribute("element", IsNullable = false)]
        public List<Element> ElementList { get; set; }

        /// <summary>
        /// 标识列
        /// </summary>
        [XmlElementAttribute("signnodeList", IsNullable = false)]
        public SignnodeList SignnodeList { get; set; }

        /// <summary>
        /// 条件集合
        /// </summary>
        [XmlElementAttribute("condition", IsNullable = false)]
        public List<Condition> ConditionList {
            get { return _conditions; }
            set { _conditions = value; }
        }

        private List<Condition> _conditions = new List<Condition>();

        /// <summary>
        /// 包含优选数据源
        /// </summary>
        [XmlAttribute("包含优选数据源")]
        public string ContainSources { get; set; }
    }

    /// <summary>
    /// 数据节点属性
    /// </summary>
    public class Element
    {
        /// <summary>
        /// 属性名称
        /// </summary>
        [XmlAttribute("名称")]
        public string Name { get; set; }
        /// <summary>
        /// 优先级
        /// </summary>
        [XmlAttribute("优先级")]
        public string Priority { get; set; }

        /// <summary>
        /// 条件集合
        /// </summary>
        [XmlElementAttribute("condition", IsNullable = false)]
        public List<Condition> ConditionList
        {
            get { return _conditions; }
            set { _conditions = value; }
        }

        private List<Condition> _conditions = new List<Condition>();

        /// <summary>
        /// 是否包含优选
        /// </summary>
        [XmlAttribute("是否包含优选")]
        public string IsContain { get; set; }
    }

    /// <summary>
    /// 标识属性集合
    /// </summary>
    public class SignnodeList
    {
        /// <summary>
        /// 标识列集合
        /// </summary>
        [XmlElementAttribute("signnode")]
        public List<Signnode> NodeList { get; set; }
    }

    /// <summary>
    /// 标识属性
    /// </summary>
    public class Signnode
    {
        /// <summary>
        /// 属性名称
        /// </summary>
        [XmlAttribute("code")]
        public string Code { get; set; }

        

        /// <summary>
        /// 条件集合
        /// </summary>
        [XmlElementAttribute("condition", IsNullable = false)]
        public List<Condition> ConditionList
        {
            get { return _conditions; }
            set { _conditions = value; }
        }

        private List<Condition> _conditions = new List<Condition>();
    }

    /// <summary>
    /// 要素优选配置信息
    /// </summary>
    [Serializable]
    [XmlRootAttribute("root", IsNullable = false)]
    public class OptimizeElementConfig
    {
        /// <summary>
        /// 数据源
        /// </summary>
        [XmlElementAttribute("sourcedatadefine", IsNullable = false)]
        public List<Sourcedatadefine> Sourcedatadefine { get; set; }

        /// <summary>
        /// 要素配置信息
        /// </summary>
        [XmlElementAttribute("casetype", IsNullable = false)]
        public List<CaseType> CaseTypeList { get; set; }
    }

    /// <summary>
    /// 优选类型
    /// </summary>
    public class CaseType
    {
        /// <summary>
        /// 诉讼地位编号
        /// </summary>
        [XmlAttribute("code")]
        public string Code { get; set; }

        /// <summary>
        /// 诉讼地位名称
        /// </summary>
        [XmlAttribute("名称")]
        public string Name { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [XmlAttribute("role")]
        public string Role { get; set; }

        /// <summary>
        /// 获取角色优选配置
        /// </summary>
        [XmlElementAttribute("xmlfacttype", IsNullable = false)]
        public List<XmlFactType> XmlFactTypeList { get; set; }
    }

    /// <summary>
    /// 要素类型
    /// </summary>
    public class XmlFactType
    {
        /// <summary>
        /// 要素类型
        /// </summary>
        [XmlAttribute("type")]
        public string Type { get; set; }

        /// <summary>
        /// 要素根路径
        /// </summary>
        [XmlAttribute("xpath")]
        public string Xpath { get; set; }

        /// <summary>
        /// 备注信息
        /// </summary>
        [XmlAttribute("remark")]
        public string Remark { get; set; }

        /// <summary>
        /// 数据节点配置集合
        /// </summary>
        [XmlElementAttribute("xmllable", IsNullable = false)]
        public List<Xmllable> XmllableList { get; set; }
    }

    /// <summary>
    /// 相同文书合并配置
    /// </summary>
    [Serializable]
    [XmlRootAttribute("root", IsNullable = false)]
    public class XmlMultipleConfig 
    {
        /// <summary>
        /// 数据节点配置集合
        /// </summary>
        [XmlElementAttribute("xmllable", IsNullable = false)]
        public List<Xmllable> XmllableList { get; set; }
    }

    /// <summary>
    /// 优选条件
    /// </summary>
    [XmlRootAttribute("condition", IsNullable = false)]
    public class Condition
    {
        /// <summary>
        /// 条件XML路径
        /// </summary>
        [XmlAttribute("where")]
        public string where { get; set; }

        /// <summary>
        /// 计算运算符 = > < !=
        /// </summary>
        [XmlAttribute("operation")]
        public string operation { get; set; }


        [XmlAttribute("value")]
        public string value { get; set; }

        /// <summary>
        /// 是否覆盖 1.覆盖
        /// </summary>
        [XmlAttribute("iscover")]
        public string IsCover { get; set; }

        /// <summary>
        /// 条件集合
        /// </summary>
        [XmlElementAttribute("condition")]
        public List<Condition> ConditionList
        {
            get { return _conditions; }
            set { _conditions = value; }
        }

        private List<Condition> _conditions = new List<Condition>();

        /// <summary>
        /// 正则编号
        /// </summary>
        [XmlAttribute("regcode")]
        public string RegCode { get; set; }
    }
}
